package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.UserBean;
import com.project.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private IUserService userService;

    @RequestMapping("findByItem")
    public IPage<UserBean> findByItem(int pageNO,String code){
        return userService.findByItem(pageNO,code);
    }

    @RequestMapping("add")
    public String add(UserBean user,int[] roleArray){
        userService.add(user,roleArray);
        return "ok";
    }

    @RequestMapping("findById")
    public UserBean findById(int id){
        return userService.findById(id);
    }

    @RequestMapping("update")
    public String update(int userId,int[] roleArray){
        userService.updateRole(userId,roleArray);
        return "ok";
    }
}
